#!/usr/bin/env python
# coding:utf-8
'''
Created on 2011-12-6

@author: bobo
'''


from M2Crypto import SSL

ctx = SSL.Context('sslv3')
addr = ("localhost", 9999)

# If you comment out the next 2 lines, the connection won't be secure
#ctx.set_verify(SSL.verify_peer, depth=0)
ctx.set_verify(0, depth=5)
c = SSL.Connection(ctx)
c.connect(addr) # automatically checks cert matches host

def send_read(c, data):
        c.send(data)
        while 1:
                rec = c.read()
                #print rec
                if rec != '':
                        print rec
                        break

send_read(c, 'AUT password')
send_read(c, 'GET timeline')
c.send("BYE BYE")

c.close()
print 'client exit'
